package com.dong.config;

import com.dong.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * Spring 4  Conditional: 当满足一定条件,才向容器中注册bean
 *
 * {@link Conditional} 也可以放到配置类上面
 *
 */
@Configuration
public class T022ConditionConfig {
    /**
     * 传递是condition数组, 与的关系
     * @return
     */
    @Bean
    @Conditional(MyCondition.class)
    Person person () {
        return new Person("李四",22);
    }
}
